/***************************************
	文件：RoundToGoal.cs
	作者：林文豪
	日期：2021-05-16
	功能：1、
****************************************/

using System.Collections.Generic;

namespace MyGame.AI.GOAP {
	public class RoundToGoal {
		private IGoal         _Goal;
		private List<IAction> _AllActionsToGoal;
		
		public IGoal         Goal             => _Goal;
		public List<IAction> AllActionsToGoal => _AllActionsToGoal;

		public RoundToGoal(MultiwayTreeNode node) {
			MultiwayTreeNode temp = node.GetCopy();
			while (temp.Parent != null) {
				if (temp.Content is IAction action) {
					_AllActionsToGoal.Add(action);
				}
				else if (temp.Content is IGoal goal) {
					_Goal = goal;
				}
				temp = temp.Parent;
			}

			_AllActionsToGoal.Reverse();
		}
	}
}
